<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"    uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
    
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">优惠券管理 &nbsp;-&nbsp;优惠券模板</li>
      <li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
    </ol>
    
    <div class="ms-content-layout has-operation">

      <div class="ms-operation-bar no-margin no-bottom-border clearfix">
        <div class="ms-operation-group pull-right">
          <a href="${ctx.host}/coupon-template/add" class="btn ms-btn ms-btn-blue" data-target="#add" data-toggle="modal">
            <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;添加模板
          </a>
          <a href="${ctx.host}/coupon-template/search${not empty queryString ? '?'.concat(queryString) : ''}" class="btn ms-btn ms-btn-blue" data-target="#search" data-toggle="modal">
            <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
          </a>
        </div>
      </div>

      <table class="table table-hover ms-table">
        <thead>
          <tr>
            <th>序号</th>
            <th>优惠券名称</th>
            <th>面值</th>            
            <th class="text-center">操作</th>
          </tr>
        </thead>
        <tbody>
           <c:forEach items="${couponTemplates}" var="couponTemplate">
                <tr>
                  <td>${couponTemplate.id}</td>
                  <td>${couponTemplate.name}</td>
                  <td><fmt:formatNumber type="percent" maxFractionDigits="2"  pattern="0.00" value="${couponTemplate.amount/100}" />元</td>
                  <td class="text-center">
                    <a href="${ctx.host}/coupon-template/${couponTemplate.id}" class="hover-no-text-decoration" title="详情">详情</a>
                  </td>
                </tr>
              </c:forEach>
                      
        </tbody>
        <tfoot>
          <tr>
            <td colspan="9" class="no-vertical-padding">
              <div class="pull-left">
                <jsp:include page="/WEB-INF/include/page.jsp">
                  <jsp:param name="url" value="${ctx.host}/coupon-template" />
                      <jsp:param name="queryString" value="${queryString}"/>
                </jsp:include>
              </div>
            </td>
          </tr>
        </tfoot>
      </table>
    </div>
  </div> 

  <%@ include file="/WEB-INF/include/footer.jsp"%>
  <%@ include file="/WEB-INF/include/script.jsp"%>
  
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/encommerce/coupon/coupon-template-list.js" />
  <script type="text/javascript">
  	  require(['page/encommerce/coupon/coupon-template-list'], function(page) {
      page.init()
      })
  </script>
  
</body>
</html>